#!/usr/bin/env bash

AEG_CNT=$#
# PMBus=""
# ProductType=""
# Psu1Mode=""
# Psu2Mode=""
H=""
U=""
P=""
IPMI=""

i=1
while [ $i -le $AEG_CNT ];do
    case ${!i} in
        -H)
            i=$(expr $i + 1)
            H=${!i}
            ;;
        -U)
            i=$(expr $i + 1)
            U=${!i}
            ;;
        -P)
            i=$(expr $i + 1)
            P=${!i}
            ;;
        *)   
            echo "outband : ./$0 -H xxx -U xxx -P xxx"
            echo "inband  : ./$0"
            exit 0
        ;;
    esac
    i=$(expr $i + 1)
done
if [ "$H" = "" ] || [ "$U" = "" ] || [ "$P" =  "" ];
then
    if [ "$H" = "" ] && [ "$U" = "" ] && [ "$P" =  "" ];
    then
        IPMI="ipmitool"
        echo "Inband mod"
    else
        echo "Outband configuration parameter error! Please enter the correct parameters." >> "$log"
        echo "Exp: $0 -H xxx -U xxx -P xxx" 
        exit -1
    fi
else
    IPMI="ipmitool -I lanplus -H $H -U $U -P $P"
    echo "Outband mod" 
    echo "Target is $H" 
fi
